package jeu.terrains
{
	import away3d.core.utils.Cast;
	import away3d.materials.*;
	import away3d.primitives.Plane;
	
	import flash.display.*;
	import flash.events.*;
	import flash.net.URLRequest;
		
	
	
	public class CatanHexagone extends Plane
	{
		private var _unite:int;

		private var _centreX:Number;
		private var _centreY:Number;

		private var _typeTerrain:String;

		public static const HEXA_DESERT:String = "TERR00";
		public static const HEXA_FORET:String = "TERR01";
		public static const HEXA_PATURAGE:String = "TERR02";
		public static const HEXA_CHAMPS:String = "TERR03";
		public static const HEXA_COLLINE:String = "TERR04";
		public static const HEXA_MONTAGNE:String = "TERR05";
		public static const HEXA_MERS:String = "TERR10";
		public static const HEXA_PORT2BOIS:String = "TERR11";
		public static const HEXA_PORT2LAINE:String = "TERR12";
		public static const HEXA_PORT2BLE:String = "TERR13";
		public static const HEXA_PORT2ARGILE:String = "TERR14";
		public static const HEXA_PORT2MINERAI:String = "TERR15";
		public static const HEXA_PORT3TOUS:String = "TERR16";
		
		private var _valeurDeCorr:int;
		
		private var _niveau:int;
		
		
		private var _chargeur:Loader;
		private var _requete:URLRequest;
		private var _image:BitmapMaterial;
		private var _nomImage:String;
		
		
		private var init:Object = null;
		
		//[Embed(source="Ressources/terrains/"+_typeTerrain+".png")]
		//private var earthBitmap:Class;
		
		public function CatanHexagone(unite:int, centreX:int, centreY:int, typeTerrain:String, valeurDeCorr:int)
		{
			
			_unite = unite;
			_centreX = centreX;
			_centreY = centreY;
			_typeTerrain = typeTerrain;
			_valeurDeCorr = valeurDeCorr;
			
			_nomImage = "Ressources/terrains/png/"+_typeTerrain+".png";
			//_nomImage = "D:/#INSA/0(3-5)INFO/4IF-ProjetReseaux-Catan/Logiciel/CatanProjet/bin-debug/Ressources/terrains/"+_typeTerrain+".png";
			_image = new BitmapFileMaterial(_nomImage);
			_image.smooth = true;
			
			
			/*
			
			_chargeur = new Loader();
			_requete = new URLRequest(_nomImage);
			//_chargeur.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
			_chargeur.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadComplete);
			_chargeur.load(_requete);
			*/
			
			
			//this.material = _image.bitmapData;
			//super();
			//var init:Object = null;
			//init.material = new BitmapMaterial(_image.bitmapData, {smoothing:true})
			//super(init);
			//super(new BitmapFileMaterial(_nomImage));
			
			//var earthMaterial:BitmapMaterial = new BitmapMaterial( Cast.bitmap(earthBitmap) );

			super({material:_image});
			//this. = _image.bitmapData;
			//super(init);
			
		}
		
		/*private function onProgress(evt:ProgressEvent)
		{
			p = (evt.bytesLoaded*100)/evt.bytesTotal;
			trace(p);
		}*/
		/*
		private function imageLoadComplete(e:Event):void 
		{
			_image = new BitmapFileMaterial(_nomImage);
			
			_image = _chargeur.content as Bitmap;
			trace(_image);
			//init.material = new BitmapMaterial(_image.bitmapData, {smoothing:true});
			//_image.bitmapData.transparent = false;
			
			//this.addChild(_chargeur);
		}*/
	}
}